﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="d" uri="/WEB-INF/resource.tld" %>

<fmt:setBundle basename="ApplicationMessage" />
<fmt:setLocale value="zh_CN" />

<sec:authentication property="principal" var="currentPrincipal" scope="page" />

<!DOCTYPE html>
<html lang="zh-CN">
<head>

  <%@ include file="/WEB-INF/include/meta.jsp"%>
  <%@ include file="/WEB-INF/include/css.jsp"%>

</head>

<body>

  <%@ include file="/WEB-INF/include/header.jsp"%>
  
  <%@ include file="/WEB-INF/include/menu.jsp"%>

  <div class="container main-content">

    <div class="panel panel-default x-panel x-panel-layout">

      <div class="panel-heading">
        <ol class="breadcrumb clearfix">
          <li><a href="${ctx.host}/ecommerce">电商管理</a></li>
          <li class="active">优惠券管理</li>
          <li class="no-before pull-right" style="min-width: 65px;">
            <a onclick="window.history.back();"><i class="glyphicon glyphicon-arrow-left"></i>&nbsp;&nbsp;返回</a>
          </li>
        </ol>
      </div>

      <div class="panel-body">

        <div class="col-xs-2 x-panel-layout-left no-horizontal-padding">
          <%@ include file="/WEB-INF/include/submenu.jsp"%>
        </div>

        <div class="col-xs-10 x-panel-layout-right">

          <div class="x-breadcrumb-wrapper">
            <div class="x-breadcrumb clearfix">
              <h2><i class="glyphicon glyphicon-fire"></i>&nbsp;&nbsp;<span>优惠券管理&nbsp;-&nbsp;模版详情</span></h2>
            </div>
          </div>
          
          <div class="x-breadcrumb-wrapper" style="margin-top: 20px;">
            <div class="x-breadcrumb yellow clearfix">
              <h2>
                <span>基本信息</span>
              </h2>
              <c:if test="${currentPrincipal.admin or currentPrincipal.root}">
                <a href="${ctx.host}/coupon-templates/${couponTemplate.id}/edit" data-target="#coupon-template-edit" data-toggle="modal" class="hover-no-text-decoration" style="position: absolute; right: 0px; top: 0px; margin-top: 10px; margin-right: 10px;" title="编辑信息">编辑信息</a>
                <a href="${ctx.host}/coupon-templates/${couponTemplate.id}/edit-description" data-target="#coupon-template-edit-description" data-toggle="modal" class="hover-no-text-decoration" style="position: absolute; right: 0px; top: 0px; margin-top: 10px; margin-right: 100px;" title="编辑使用规则">编辑使用规则</a>
              </c:if>
            </div>
          </div>
          
          <div class="form-horizontal" style="margin-top: 20px;">
            <div class="form-group">
              <label class="col-xs-2 control-label">优惠券名称：</label>
              <div class="col-xs-4 pull-left">
                <p class="form-control-static">${couponTemplate.name}</p>
              </div>
              
              <label class="col-xs-2 control-label">折扣类型：</label>
              <div class="col-xs-4 pull-left">
                <p class="form-control-static">${couponTemplate.discountType.description}</p>
              </div>
            </div>
            <c:if test="${couponTemplate.discountType.isFixedAmount()}">
              <div class="form-group">
                <label class="col-xs-2 control-label">面值：</label>
                <div class="col-xs-4 pull-left">
                  <p class="form-control-static">${couponTemplate.amount/100}元</p>
                </div>
                
                <label class="control-label col-xs-2">最低消费金额：</label>
                <div class="col-xs-4 pull-left">
                  <p class="form-control-static">${couponTemplate.minAmount/100}元</p>
                </div>
              </div>
            </c:if>
            
            <div class="form-group">
              <label class="col-xs-2 control-label">类型：</label>
              <div class="col-xs-4 pull-left">
                <p class="form-control-static">${couponTemplate.type.description}</p>
              </div>
              
              <c:if test="${couponTemplate.type.isProduct() }">
                <label class="col-xs-2 control-label">产品名称：</label>
                <div class="col-xs-4 pull-left">
                  <p class="form-control-static">${couponTemplate.product.name }</p>
                </div>
              </c:if>
              <c:if test="${couponTemplate.type.isCategory() }">
                <label class="col-xs-2 control-label">类别：</label>
                <div class="col-xs-4 pull-left">
                  <p class="form-control-static">${couponTemplate.productType.description}</p>
                </div>
              </c:if>
            </div>
            
            <div class="form-group">
              <label class="col-xs-2 control-label">创建时间：</label>
              <div class="col-xs-4 pull-left">
                <p class="form-control-static">
                  <fmt:formatDate value="${couponTemplate.createTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
                </p>
              </div>
              
              <label class="col-xs-2 control-label">可转赠：</label>
              <div class="col-xs-4 pull-left">
                <p class="form-control-static">
                  ${couponTemplate.giveAvailable ? '是' : '否'}
                </p>
              </div>
            </div>
            
            <div class="form-group">
              <label class="col-xs-2 control-label">使用规则：</label>
              <div class="col-xs-10 pull-left">
                <p class="form-control-static">
                  ${couponTemplate.description}
                </p>
              </div>
            </div>
          </div>
          
          <div class="x-breadcrumb-wrapper top-margin-20">
            <div class="x-breadcrumb yellow clearfix">
              <h2>
                <span>统计信息</span>
              </h2>
            </div>
          </div>
          
          <div class="form-horizontal" style="margin-top: 20px;">
            
            <div class="form-group">
              <label class="col-xs-2 control-label">生成批次数：</label>
              <div class="col-xs-4 pull-left"><p class="form-control-static">${persist.couponTemplateStat(couponTemplate.id).batchCount}</p></div>
              <label class="col-xs-2 control-label">总发放数：</label>
              <div class="col-xs-4 pull-left"><p class="form-control-static">${persist.couponTemplateStat(couponTemplate.id).totalCount}</p></div>
            </div>
            
            <div class="form-group">
              <label class="col-xs-2 control-label">总使用数：</label>
              <div class="col-xs-4 pull-left"><p class="form-control-static">${persist.couponTemplateStat(couponTemplate.id).usedCount}</p></div>
              <label class="col-xs-2 control-label">过期数：</label>
              <div class="col-xs-4 pull-left"><p class="form-control-static">${persist.couponTemplateStat(couponTemplate.id).overdueCount}</p></div>
            </div>
            
            <div class="form-group">
              <c:if test="${couponTemplate.discountType.fixedAmount}">
                <label class="col-xs-2 control-label">总优惠金额：</label>
                <div class="col-xs-4 pull-left"><p class="form-control-static">${persist.couponTemplateStat(couponTemplate.id).amount/100}元</p></div>
              </c:if>
              <label class="col-xs-2 control-label">实际优惠金额：</label>
              <div class="col-xs-4 pull-left"><p class="form-control-static">${persist.couponTemplateStat(couponTemplate.id).actualAmount/100}元</p></div>
            </div>
          </div>
          
        </div>

      </div>
      
    </div>
    
  </div>

  <%@ include file="/WEB-INF/include/script.jsp"%>
  <d:resource root="${ctx.resource}/build" type="script" src="js/page/encommerce/coupon/coupon-template-view.js">
    <script type="text/javascript">
      require(['page/encommerce/coupon/coupon-template-view'], function(page) {
        page.init()
      })
    </script>
  </d:resource>
</body>

</html>